package luanluan.utils 
{
	import flash.net.LocalConnection;
	import flash.system.ApplicationDomain;
	/**
	 * ...
	 * @author luanluan
	 */
	public class LuanSystem 
	{
		
		/**
		 * 根据类名获取类对象
		 * @param	className 类名
		 * @return	返回类
		 */
		static public function getClass(className:String , appDomain:ApplicationDomain = null):Class
		{
			if (appDomain == null)
				appDomain = ApplicationDomain.currentDomain;
			return appDomain.getDefinition(className) as Class;
		}
		
		/**
		 * 根据类名获取一个该类的新实例
		 * @param	className
		 * @param	appDomain
		 * @return
		 */
		static public function getObjectByClassName(className:String , appDomain:ApplicationDomain = null):*
		{
			if (appDomain == null)
				appDomain = ApplicationDomain.currentDomain;
			var objClass:Class = appDomain.getDefinition(className) as Class;
			return new objClass();
		}
		
		/**
		 * 获取对象的类
		 * @param	obj
		 * @return
		 */
		public static function getObjClass(obj:*):Class
		{
			if (obj is Class)
				return obj;
			var objClass:Class = obj.constructor as Class;
			return objClass;
		}
		
		/**
		 * 强制启动垃圾回收
		 */
		public static function gc():void
		{
			try 
			{
				new LocalConnection().connect("luanluan");
				new LocalConnection().connect("luanluan");
			}
			catch (e:Error)
			{
				
			}
		}
	}

}